<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set active foreground and background colors</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ncurses-color-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ncurses_color_set</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5 &lt; 5.3.0, PECL ncurses &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">ncurses_color_set</span> &mdash; <span class="dc-title">Set active foreground and background colors</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.ncurses-color-set-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ncurses_color_set</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$pair</code></span>
   ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Sets the active foreground and background colors. Any characters written
   after this function is invoked will have these colors. This function requires
   terminal colors to be supported and initialized using
   <span class="function"><a href="ncurses_start_color.html" class="function">ncurses_start_color()</a></span> beforehand.
  </p>
  <p class="para">
   ncurses uses color pairs to specify both foreground and background colors.
   Use <span class="function"><a href="ncurses_init_pair.html" class="function">ncurses_init_pair()</a></span> to define a color pair.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.ncurses-color-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">pair</code></dt>

     <dd>

      <p class="para">
       The color pair from which to get the foreground and background colors
       to set as the active colors.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.ncurses-color-set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <em>-1</em> on success, and <em>0</em> on failure.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.ncurses-color-set-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-679">
    <p><strong>Example #1 Writing a string with a specified color to the screen</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ncurses_init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;If&nbsp;the&nbsp;terminal&nbsp;supports&nbsp;colors,&nbsp;initialize&nbsp;and&nbsp;set&nbsp;active&nbsp;color<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">ncurses_has_colors</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ncurses_start_color</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ncurses_init_pair</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NCURSES_COLOR_YELLOW</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NCURSES_COLOR_BLUE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ncurses_color_set</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Write&nbsp;a&nbsp;string&nbsp;at&nbsp;specified&nbsp;location<br /></span><span style="color: #0000BB">ncurses_mvaddstr</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Hello&nbsp;world!&nbsp;Yellow&nbsp;on&nbsp;blue&nbsp;text!"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Flush&nbsp;output&nbsp;to&nbsp;screen<br /></span><span style="color: #0000BB">ncurses_refresh</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">ncurses_end</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.ncurses-color-set-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="ncurses_init_pair.html" class="function" rel="rdfs-seeAlso">ncurses_init_pair()</a> - Define a color pair</span></li>
    <li class="member"><span class="function"><a href="ncurses_start_color.html" class="function" rel="rdfs-seeAlso">ncurses_start_color()</a> - Initializes color functionality</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>